// TOWN SCRIPT
//    Town 8: Beach

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,choice;
short lead_char;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered

remove_char_from_party(101);
remove_char_from_party(300);

 i = 0;
 while (i < 5) {
  if (char_ok(i)) {
   lead_char = i;
   i = 5;
  }
  else
   i = i + 1;
 }
	
if (get_sdf(100,0) > 0)
 message_dialog("You head down the passage, and, as promised, you find the shore. From here you continue your exploration. You find several mineral deposits and other geological features.","");

relocate_character(0,15,15);
relocate_character(1,16,15);
relocate_character(2,17,15);
relocate_character(3,18,15);
set_character_facing(0,0);
set_character_facing(1,0);
set_character_facing(2,0);
set_character_facing(3,0);
force_view_center(16,14);

 set_crime_tolerance(1);

break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;

set_state_continue(10);

break;


beginstate 10;

pause(20);

if (get_sdf(100,0) == 0) {
 change_coins(500);
 reset_dialog();
 add_dialog_str(0,"You have finally reached the shore. You follow it around and map as much of the island as possible. You find some isolated Nephilim settlements, but nothing as grand as Vikida.",0);
 add_dialog_str(1,"After a few months, the ship arrives to pick you up. A bladesman in the Imperial Navy disembarkes and asks for a report.",0);
 add_dialog_choice(0,"OK.");
 choice = run_dialog(1);
 set_state_continue(11);
}
else {
 change_coins(1000);
 reset_dialog();
 add_dialog_str(0,"You find yourself on a beach far from Vikida. The cost of the fight was high. Arivan, Klinger, Suvar, Valzier, and so many others are dead, sacrificed to an impossible idea of perfection.",0);
 add_dialog_str(1,"All of this was caused by a warped ancient spirit, trapped by some alien spirit snare. Its ideas poisoned the minds of the inhabitants of this forest and brought great suffering. You hope now that the spirit decides to leave.",0);
 add_dialog_str(2,"You eventually do more exploring and, after a few months, the ship arrives to take you home. A bladesman in the Imperial Navy disembarkes and asks for a report.",0);
 add_dialog_choice(0,"OK.");
 choice = run_dialog(1);
 set_state_continue(12);
}

break;


beginstate 11;

pause(10);
text_bubble_on_char(6,"Anything interesting?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"We found Nephil.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Isn't this island uninhabited?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"So we thought...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...but there are natives here.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"That's interesting.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Anything else?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"We found mineral deposits...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...herbs, native animals, and such.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"We have mapped them out.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Good!");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"The Empire will be interested,");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"but we should get going.");
force_instant_terrain_redraw();
pause(20);

text_bubble_on_char(6,"");
set_character_facing(6,0);
relocate_character(6,char_loc_x(6),char_loc_y(6) - 1);
force_instant_terrain_redraw();
pause(5);

relocate_character(6,char_loc_x(6),char_loc_y(6) - 1);
force_instant_terrain_redraw();
pause(5);

 reset_dialog();
 add_dialog_str(0,"You board the ship and head home. You are given your fee of 500 coins. Not a whole lot, but in these times, anything you can get is good.",0);
 add_dialog_str(1,"As you sail on, you can't help but feel there was much more to find than a genocidal tribe of Nephilim. Oh well, it's not that important to you.",0);
 add_dialog_choice(0,"THE END.");
 choice = run_dialog(1);

end_scenario(0);

break;


beginstate 12;

pause(20);
text_bubble_on_char(6,"Anything interesting?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"We found Nephil.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Isn't this island uninhabited?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"There's more!");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"The tribes here practiced...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...mass murder on each other.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"So.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Why should we care?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"That's not all.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"We discovered alien technology.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Tell me more.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"We found many old bases.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"One had a device...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...that trapped spirits here.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Hmmmm...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Our mages will be interested.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"Afraid it was destroyed.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"A special spirit was trapped.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"It radiated thoughts that caused...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...the Nephils to commit genocide.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"We investigated...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...and found the spirit.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"To save ourselves...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...we had to destroy the device.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"That's too bad.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"What happened to the spirit?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"It left this world, we hope.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"With the device gone...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...it could escape.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"Fortunately, there are other...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"...alien relics on this island.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(lead_char,"The Empire should explore.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Indeed we will.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"The Empire is pleased...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"...with your report.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"I suspect you'll get a bonus.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Nice work.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"Thank you.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Come.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"We must be leaving.");
force_instant_terrain_redraw();
pause(20);


text_bubble_on_char(6,"");
set_character_facing(6,0);
relocate_character(6,char_loc_x(6),char_loc_y(6) - 1);
force_instant_terrain_redraw();
pause(5);

relocate_character(6,char_loc_x(6),char_loc_y(6) - 1);
force_instant_terrain_redraw();
pause(5);

set_character_facing(6,4);
force_instant_terrain_redraw();
pause(5);

text_bubble_on_char(6,"");
text_bubble_on_char(6,"Also...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"What you saw on this isle...");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"...is considered secret.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Mention it to no one.");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Understood?");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(lead_char,"Yes sir!");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(lead_char,"");
text_bubble_on_char(6,"Good!");
force_instant_terrain_redraw();
pause(20);
text_bubble_on_char(6,"");
text_bubble_on_char(6,"Let's go!");
force_instant_terrain_redraw();
pause(20);

text_bubble_on_char(6,"");
set_character_facing(6,0);
relocate_character(6,char_loc_x(6),char_loc_y(6) - 1);
force_instant_terrain_redraw();
pause(5);

 reset_dialog();
 add_dialog_str(0,"You board the ship and head home. You are given your fee of 500 coins plus a bonus of 500 coins. Not a whole lot for what you went through, but in these times, anything you can get is good.",0);
 add_dialog_str(1,"As you sail into the sunset, you wonder what happened to the inhabitants of Valzakov and the alien technology there. You never hear; the Empire is far too secretive these days, and you never mention what you saw there.",0);
 add_dialog_str(2,"You hope the Perfect Spirit left this world forever. A part of you suspects that this world has not seen the last of its horrible effects. However, those are answers for another day.",0);
 add_dialog_choice(0,"THE END.");
 choice = run_dialog(1);

end_scenario(1);

break;
